package com.gisocn.onemap.widget;

import android.content.Context;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import androidx.viewpager.widget.ViewPager;
import com.gisocn.onemap.utils.L;

/* loaded from: classes2.dex */
public class MyViewPager extends ViewPager {
    PointF curP;
    PointF downP;
    private boolean scrollble;

    public MyViewPager(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.scrollble = true;
        this.downP = new PointF();
        this.curP = new PointF();
    }

    public MyViewPager(Context context) {
        super(context);
        this.scrollble = true;
        this.downP = new PointF();
        this.curP = new PointF();
    }

    public boolean isScrollble() {
        return this.scrollble;
    }

    public void setScrollble(boolean z) {
        this.scrollble = z;
    }

    @Override // androidx.viewpager.widget.ViewPager, android.view.ViewGroup
    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        if (this.scrollble) {
            return super.onInterceptTouchEvent(motionEvent);
        }
        return false;
    }

    @Override // androidx.viewpager.widget.ViewPager, android.view.View
    public boolean onTouchEvent(MotionEvent motionEvent) {
        L.e("onTouchEvent");
        if (this.scrollble) {
            if (getChildCount() <= 1) {
                return super.onTouchEvent(motionEvent);
            }
            this.curP.x = motionEvent.getX();
            this.curP.y = motionEvent.getY();
            if (motionEvent.getAction() == 0) {
                this.downP.x = motionEvent.getX();
                this.downP.y = motionEvent.getY();
                getParent().requestDisallowInterceptTouchEvent(true);
            }
            if (motionEvent.getAction() == 2) {
                getParent().requestDisallowInterceptTouchEvent(true);
            }
            if (motionEvent.getAction() == 1 || motionEvent.getAction() == 3) {
                if (this.curP.x - this.downP.x > 0.0f && Math.abs(this.curP.x - this.downP.x) > 25.0f) {
                    L.e("向左边滑动");
                } else if (this.curP.x - this.downP.x < 0.0f && Math.abs(this.curP.x - this.downP.x) > 25.0f) {
                    L.e("向右边滑动");
                }
                getParent().requestDisallowInterceptTouchEvent(false);
                if (this.downP.x == this.curP.x && this.downP.y == this.curP.y) {
                    return true;
                }
            }
            super.onTouchEvent(motionEvent);
            return true;
        }
        return false;
    }
}
